package org.yaukie.startup.impl;


 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.yaukie.ClassCacheFactory;
import org.yaukie.helper.ConfigHelper;
import org.yaukie.startup.inter.MyJobOnStartUpInitializer;

import javax.servlet.ServletContext;


/**
 *  @Author: yuenbin
 *  @Date :2020/5/16
 * @Time :14:22
 * @Motto: It is better to be clear than to be clever !
 * @Destrib:  创建定时器启动开始类
**/
public class MyJobOnStartUpInitializerImpl implements MyJobOnStartUpInitializer {

	private static Logger logger = LoggerFactory.getLogger(MyJobOnStartUpInitializerImpl.class);

	@Override
	public void init(ServletContext servletContext) {

		if(logger.isDebugEnabled())
		{
			logger.debug("MyJobOnStartUpInitializerImpl init starts ....");
		}

		//如果需要随应用开启定时器，则启动所有的定时任务
		if(ConfigHelper.isAutoOn()){
			ClassCacheFactory.getMyJobInstance().startAllJob();
		}else{
			if(logger.isDebugEnabled())
			{
				logger.debug("定时任务暂未开启....");
			}
		}

		if(logger.isDebugEnabled())
		{
			logger.debug("MyJobOnStartUpInitializerImpl init ends ....");
		}

	}
}
